//
//  HLSplitViewController.m
//  CommonProject
//
//  Created by 任翰林 on 16/6/11.
//  Copyright © 2016年 任翰林. All rights reserved.
//

#import "HLSplitViewController.h"
#import "HLMasterViewController.h"
#import "HLDetailViewController.h"
@interface HLSplitViewController ()

@property(nonatomic ,strong)HLMasterViewController * masterVC;

@end

@implementation HLSplitViewController

- (instancetype)init
{
    self = [super init];
    if (self) {
        
        self.masterVC = [[HLMasterViewController alloc]init];
        self.masterVC.view.backgroundColor = [UIColor lightGrayColor];
        [self addChildViewController:self.masterVC];
        [self.view addSubview:self.masterVC.view];
        
        HLDetailViewController * detailVC = [[HLDetailViewController alloc]init];
        detailVC.view.backgroundColor = [UIColor blueColor];
        [self addChildViewController:detailVC];
        [self.view  addSubview:detailVC.view];
        
        
    }
    return self;
}




- (void)viewDidLoad {
    [super viewDidLoad];
    
//   设置展示样式
    self.preferredDisplayMode = UISplitViewControllerDisplayModeAutomatic;
    self.preferredPrimaryColumnWidthFraction = 0.5;
    
//    接收系统发过来的通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationDidChangeNotification) name:UIDeviceOrientationDidChangeNotification object:nil];
    
    
}


//系统通知的方法的实现,每一次改变横竖屏的时候系统都会发送一个通知，所以会调用这个方法。
- (void)orientationDidChangeNotification
{

  BOOL result =  UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation);
    
    if (result) {
        NSLog(@"这里是竖屏");
        self.maximumPrimaryColumnWidth = 80;
        
    } else {
    
        self.maximumPrimaryColumnWidth = 200;
        NSLog(@"这里是横屏");
        
    
    }

    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
